/*  
   File Browser for SalesForce
   Copyright (c) 2009  Daniel Jordan
  
   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License
   as published by the Free Software Foundation; either version 2
   of the License, or (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
 */

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Configuration;

namespace SFFileBrowser
{
    public partial class frmOptions : Form
    {
       

        public frmOptions()
        {
            InitializeComponent();
            loadSettings();
        }


        private void buttonClose_Click(object sender, EventArgs e)
        {
            saveSettings();
            this.Hide();
        }

        private void loadSettings()
        {;
            this.textSForceToken.Text = Properties.Settings.Default.SalesForce_Token; 
            this.textSForceUser.Text = Properties.Settings.Default.SalesForce_Username; 
            this.textCache.Text = Properties.Settings.Default.Cache_Path;
            this.comboListType.Text = Properties.Settings.Default.Display_FileListType;
            this.checkShowProduct.Checked =Properties.Settings.Default.Display_Product;
            this.checkShowContactCase.Checked= Properties.Settings.Default.Display_Account_Contact_Case;
            this.checkShowAccountContact.Checked = Properties.Settings.Default.Display_Account_Contact;
            this.checkShowAccountCase.Checked=Properties.Settings.Default.Display_Account_Case;
            this.checkShowAccountOpportunity.Checked= Properties.Settings.Default.Display_Account_Opportunity;
            this.checkShowCampaign.Checked = Properties.Settings.Default.Display_Campaign;
            this.checkShowCampaignOpportunity.Checked=Properties.Settings.Default.Display_Campaign_Opportunity;
            this.checkShowSolution.Checked=Properties.Settings.Default.Display_Solution;
            this.checkShowAccountContract.Checked= Properties.Settings.Default.Display_Account_Contract;
            this.checkShowSolutionCase.Checked = Properties.Settings.Default.Display_Solution_Case;
            this.checkShowDocuments.Checked = Properties.Settings.Default.Display_Documents;
        }

        public void saveSettings()
        {

            Properties.Settings.Default.SalesForce_Token = this.textSForceToken.Text;
            Properties.Settings.Default.SalesForce_Username = this.textSForceUser.Text;
            Properties.Settings.Default.Cache_Path = this.textCache.Text;
            Properties.Settings.Default.Display_FileListType = this.comboListType.Text;
            Properties.Settings.Default.Display_Product = this.checkShowProduct.Checked;
            Properties.Settings.Default.Display_Account_Contact_Case = this.checkShowContactCase.Checked;
            Properties.Settings.Default.Display_Account_Contact = this.checkShowAccountContact.Checked;
            Properties.Settings.Default.Display_Account_Case = this.checkShowAccountCase.Checked;
            Properties.Settings.Default.Display_Account_Opportunity = this.checkShowAccountOpportunity.Checked;
            Properties.Settings.Default.Display_Campaign = this.checkShowCampaign.Checked;
            Properties.Settings.Default.Display_Campaign_Opportunity = this.checkShowCampaignOpportunity.Checked;
            Properties.Settings.Default.Display_Solution = this.checkShowSolution.Checked;
            Properties.Settings.Default.Display_Account_Contract = this.checkShowAccountContract.Checked;
            Properties.Settings.Default.Display_Solution_Case = this.checkShowSolutionCase.Checked;
            Properties.Settings.Default.Display_Documents = this.checkShowDocuments.Checked;
            Properties.Settings.Default.Save();
            
        }

        private void frmOptions_Load(object sender, EventArgs e)
        {

        }

        private void checkShowAccountContact_CheckedChanged(object sender, EventArgs e)
        {
            if (checkShowAccountContact.Checked == false)
            {
                checkShowContactCase.Checked = false;
                checkShowContactCase.Enabled = false;
            }
        }


    }
}